Skip to content

Conversation

bigcat88
Copy link
Contributor

@bigcat88 bigcat88 commented Oct 6, 2025

This PR adds a tiny normalization step so Combo.Input can take a Python Enum class directly as options. We expand the enum to its member .value list at construction time, which:

  • eliminates repetitive [m.value for m in MyEnum] boilerplate
  • ensures options stay in sync with the enum definition

The change is backward‑compatible (existing list[str] still works) and requires no frontend adjustments. Default handling remains unchanged.

Also extended typing for options and default as they can receive ints and not only str which many API nodes passes to them.

Example of the simplification(in API nodes there is around 30 such usages):

comfy_io.Combo.Input(
    "model",
    options=Text2ImageModelName,  # old code: options=[model.value for model in Text2ImageModelName],  
    default=Text2ImageModelName.seedream_3,
    tooltip="Model name",
),

@bigcat88 bigcat88 requested a review from Kosinkadink as a code owner October 6, 2025 16:55
@Kosinkadink
Copy link
Collaborator

The only change required here would be to make sure that default gets cast to the value if it is an Enum

@Kosinkadink Kosinkadink added the v3 label Oct 6, 2025
@bigcat88 bigcat88 force-pushed the v3/combo-input-allow-enum branch from 26f2b4a to 05e12a0 Compare October 7, 2025 05:34
@bigcat88
Copy link
Contributor Author

bigcat88 commented Oct 7, 2025

The only change required here would be to make sure that default gets cast to the value if it is an Enum

done 🚀

Also rebased on the master branch and adjusted all API nodes to use this.

Objects git diff(the easiest way to check that all is ok in this case):

diff --git a/v3_object_info.json b/master_object_info.json
index 3473e15..8904ccf 100644
--- a/v3_object_info.json
+++ b/master_object_info.json
@@ -35667,11 +35667,13 @@
                     {
                         "multiselect": false,
                         "options": [
-                            "Microwave",
-                            "Suit Swagger",
-                            "Anything, Robot",
-                            "Subject 3 Fever",
-                            "kiss kiss"
+                            [
+                                "Microwave",
+                                "Suit Swagger",
+                                "Anything, Robot",
+                                "Subject 3 Fever",
+                                "kiss kiss"
+                            ]
                         ]
                     }
                 ]

Difference in the PixVerse node is a fix for error introduced during conversion to V3 here


edited: I additionally looked why PyCharm was not triggered by this simple "typing" bug in PixVerse conversion PR and found that typing got lost during assignment in the _io._IO class(at least for PyCharm)
For PyLint I was not able currently to make it catch up this error at all, maybe later I will try second pass or will check this with ruff.

I will make a separate PR regarding typing, as it requires additional research without hurry up.

@bigcat88 bigcat88 force-pushed the v3/combo-input-allow-enum branch from 05e12a0 to d17d2f6 Compare October 7, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants